<?php 
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: add.phtml 4700 2010-08-16 16:14:34Z jam-gate.vn $
 * @since		2.0.0
 */
?>
<?php 
$this->headTitle($this->translator('equipment_add_page_title'));

$this->headScript()
	->appendFile($this->APP_STATIC_SERVER . '/js/jquery.validate/jquery.validate.min.js')
	->appendFile($this->APP_STATIC_SERVER . '/js/tomato/util.js')
	->appendFile($this->APP_STATIC_SERVER . '/js/jquery.slideviewer/jquery.slideviewer.1.2.js');
?>
<link media="all" type="text/css" href="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/themes/base/ui.core.css" rel="stylesheet">				
<link media="all" type="text/css" href="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/themes/base/ui.resizable.css" rel="stylesheet">		
<link media="all" type="text/css" href="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/themes/base/ui.dialog.css" rel="stylesheet">
<link media="all" type="text/css" href="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/themes/base/ui.theme.css" rel="stylesheet">

<script language="JavaScript" type="text/JavaScript" src="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/ui.core.js"></script>		
<script language="JavaScript" type="text/JavaScript" src="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/ui.draggable.js"></script>		
<script language="JavaScript" type="text/JavaScript" src="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/ui.resizable.js"></script>
<script language="JavaScript" type="text/JavaScript" src="<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.ui/ui.dialog.js"></script>		

<!-- Style for jquery sliderView -->

<div class="grid_12 t_a_ui_breadcrumb">
	<div class="grid_11 alpha">
		<span><a href="<?php echo $this->url(array(), 'equipment_equipment_list'); ?>"><?php echo $this->translator('equipment_list_breadcrumb'); ?></a></span>
		<span><?php echo $this->translator('equipment_add_breadcrumb'); ?></span>
	</div>	
	<div class="grid_1 omega"><?php echo $this->languageSwitcher('flag', str_repeat('&nbsp;', 2)); ?></div>
</div>

<div class="grid_12"><?php echo $this->flashMessenger(); ?></div>

<form method="post" action="<?php echo $this->url(array(), 'equipment_equipment_add'); ?>" id="addEquipmentForm">
<div class="grid_12 t_a_bottom"><?php echo $this->translator('equipment_add_guide'); ?></div>

<div class="grid_12 t_a_bottom">
		<div class="grid_9 alpha">
			<div class="grid_9">
				<label><?php echo $this->translator('equipment_equipment_id'); ?>:</label>
				<input readonly="readonly" type="text" id="equipment_id" name="equipment_id" style="width: 300px" value="<?php echo $this->equipment->id;?>"/>
				<input type="hidden" id="shop_id" name="shop_id" value="<?php echo $this->equipment->shop_id;?>"/>
			</div>
			<hr/>
			<div class="grid_9">
				<label><?php echo $this->translator('equipment_name'); ?>:</label>
				<span>					
					<img src="<?php echo $this->APP_STATIC_SERVER;?>/images/flags/vi_VN.png"/>
					<input maxlength="255" type="text" id="equipment_name_vi_VN" name="equipment_name_vi_VN" style="width: 300px" value="<?php echo $this->equipment->equipment_name_vi_VN;?>"/>					
				</span>
				<div style="margin-left:160px;margin-top:5px;">				
					<span>						
						<img src="<?php echo $this->APP_STATIC_SERVER;?>/images/flags/en_US.png"/>
						<input maxlength="255" type="text" id="equipment_name_en_US" name="equipment_name_en_US" style="width: 300px" value="<?php echo $this->equipment->equipment_name_en_US;?>" />
						<a class="btnTranslate" href="javascript:void(0)" onclick="translateFrom('equipment_name_vi_VN','equipment_name_en_US',this);" title="<?php echo $this->translator("service_service_translate_from_vi");?>">
							<img src="<?php echo $this->APP_STATIC_SERVER;?>/images/icons/translate.png">
						</a>															
					</span>
				</div>				
			</div>			
			<hr/>
			<div class="grid_9">			
				<label><?php echo $this->translator("equipment_equipment_unit");?></label>
				<input style="float:left;" type="text" name="equipment_unit" id="equipment_unit" value="<?php echo $this->equipment->equipment_unit?>" size="7">
				<label style="width:auto;margin-left:5px;margin-right:5px;"><?php echo $this->translator("equipment_equipment_unit_use");?></label>
				<input style="float:left;" type="text" name="equipment_unit_use" id="equipment_unit_use" value="<?php echo $this->equipment->equipment_unit_use?>" size="7">
			</div>
			<div class="grid_9">
				<label><?php echo $this->translator("equipment_equipment_amount");?></label>
				<input style="float:left;" type="text" name="amount" id="amount" value="<?php echo $this->equipment->amount?>" size="7">
				<label style="width:auto;margin-left:5px;margin-right:5px;"><?php echo $this->translator("equipment_equipment_unit_use_per_one");?></label>				 			
				<input style="float:left;" type="text" name="volume_one" id="volume_one" value="<?php echo $this->equipment->volume_one?>" size="7">
			</div>
			<hr/>
			<div class="grid_9">
				<label><?php echo $this->translator("equipment_equipment_original_price");?></label> 
				<input type="text" name="original_price" id="original_price" value="<?php echo $this->equipment->original_price?>">
				<?php echo Zend_Auth::getInstance()->getIdentity()->shop->currency;?>
			</div>
			<hr/>
			<div class="grid_9">
				<label><?php echo $this->translator("equipment_equipment_sale_price");?></label> 
				<input type="text" name="sale_price" id="sale_price" value="<?php echo $this->equipment->sale_price?>">
				<?php echo Zend_Auth::getInstance()->getIdentity()->shop->currency;?>
			</div>
			<hr/>
			<div class="grid_9">
				<label><?php echo $this->translator("equipment_equipment_note_used");?></label>
				<textarea name="note_used" id="note_used"><?php echo $this->equipment->note_used;?></textarea>
			</div> 
			<hr/>
			<div class="grid_9" style="margin-left:240px;margin-top:20px;">
				<button type="submit"><span><?php echo $this->translator('equipment_add_save_button'); ?></span></button>			 
			</div>
		</div>		
		<div class="gird_3 omega" style="float:right;text-align:center;font-size:13px;">
			<?php
				echo $this->helperLoader('core')->listImage("images",$this->equipment->images,"equipment",$this->equipment->id); 
			?>		    
		</div>	
</div>
</form>				
<script type="text/javascript">
<<<<<<< .mine
function onUploadComplete(response) {
	console.log(response);
	var res = $.evalJSON(response);
	if(res.success== true){							
		var url = res.url;
		var rel = res.fileName;							
		$("#listEquipmentImage").find("ul li:first").before('<li><img src="'+url+'" rel="'+rel+'" width="180" height="200"/></li>');
		$("#listEquipmentImage").find(".no-image").remove();
		$("#listEquipmentImage").next(".stripTransmitter").html("");
		$("div#listEquipmentImage").slideView();
		uploadValueImages();
	}else{
		alert(res.message);	
	}
};

function translateFrom(fromId,toId,this_){
	var val = $("#"+fromId).val();
	$.translate(val, 'en', {
		  complete: function(translation){ 
		  	$("#"+toId).val(translation);
		  }
	});
	$(this_).attr("checked",true);
}
function implode( glue, pieces ) {  
    return ( ( pieces instanceof Array ) ? pieces.join ( glue ) : pieces );  
}  
function uploadValueImages(){
	var arrImg = [];
	$("#listEquipmentImage").find("img").each(function(){
		arrImg.push($(this).attr("rel"));
	});
	$("#images").val(implode(',',arrImg));	
}
=======

>>>>>>> .r21
$(document).ready(function() {
	/**
	 * Validate form
	 */
	$('#addEquipmentForm').validate({
		rules: {
			equipment_name_vi_VN: {
				required: true,
		  		maxlength: 255
			},
			equipment_name_en_US: {
				required: true,
		  		maxlength: 255
			},
			equipment_unit: {
				required:true,
				maxlength: 10
			},
			equipment_unit_use: {
				required:true,
				maxlength: 10
			},
			amount:{
				required:true,
				digits: true
			},
			volume_one:{
				required:true,
				digits: true
			},
			original_price:{
				required:true,
				digits: true
			},
			sale_price:{
				required:true,
				digits: true
			}			
	    },
	    messages: {
	    	equipment_name_vi_VN: {
	        	required: "<?php echo $this->translator('equipment_name_vi_VN_required'); ?>",
				maxlength: "<?php echo $this->translator('equipment_name_vi_VN_maxlength'); ?>"
			},
	    	equipment_name_en_US: {
	        	required:  "<?php echo $this->translator('equipment_name_en_US_required'); ?>",
				maxlength: "<?php echo $this->translator('equipment_name_en_US_maxlength'); ?>"
			},
			equipment_unit:{
				required: "<?php echo $this->translator('equipment_unit_required'); ?>",
				maxlength: "<?php echo $this->translator('equipment_unit_maxlength'); ?>"
			},
			equipment_unit_use:{
				required: "<?php echo $this->translator('equipment_unit_use_required'); ?>",
				maxlength: "<?php echo $this->translator('equipment_unit_use_maxlength'); ?>"
			},
			amount:{
				required:"<?php echo $this->translator('equipment_amount_required'); ?>",
				digits:  "<?php echo $this->translator('equipment_amount_is_digits'); ?>"
			},
			volume_one:{
				required:"<?php echo $this->translator('equipment_volume_one_required'); ?>",
				digits:  "<?php echo $this->translator('equipment_volume_one_is_digits'); ?>"
			},
			original_price:{
				required:"<?php echo $this->translator('equipment_original_price_required');?>",
				digits: "<?php  echo $this->translator('equipment_original_price_is_digits'); ?>"
			},
			sale_price:{
				required:"<?php echo $this->translator('equipment_sale_price_required');?>",
				digits: "<?php  echo $this->translator('equipment_sale_price_is_digits'); ?>"
			}
		}
	});
});
</script>
